package cn.project.action;

import cn.project.biz.Userbiz;
import cn.project.model.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Controller
@Scope(value = "prototype")
@ParentPackage("struts-default")
public class UserAction extends ActionSupport{
    @Resource(name = "userBiz")
    private Userbiz userbiz;


    @Action(value = "getallUser",results = {
            @Result(name = "success",location = "/list.jsp")
    })
    @Override
    public String execute() throws Exception {
        List<User> list=userbiz.getAllUser();
        Map requestMap= (Map) ActionContext.getContext().get("request");
          requestMap.put("list",list);
        return SUCCESS;
    }

    public Userbiz getUserbiz() {
        return userbiz;
    }

    public void setUserbiz(Userbiz userbiz) {
        this.userbiz = userbiz;
    }
}
